package com.twu.biblioteca;

/**
 * twu-biblioteca-ziyiliu
 * User: Ziyi.LIU
 * Date: 14-6-19
 */
public class Movie implements Material{
    private int id;
    private String name;
    private String director;
    private int year;
    private int rating;

    public Movie(int id, String name, String director, int year, int rating) {

        this.id = id;
        this.name = name;
        this.director = director;
        this.year = year;
        this.rating = rating;
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getDirector() {
        return director;
    }

    public int getYear() {
        return year;
    }

    public int getRating() {
        return rating;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Movie movie = (Movie) o;

        if (id != movie.id) return false;
        if (rating != movie.rating) return false;
        if (year != movie.year) return false;
        if (!director.equals(movie.director)) return false;
        if (!name.equals(movie.name)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id;
        result = 31 * result + name.hashCode();
        result = 31 * result + director.hashCode();
        result = 31 * result + year;
        result = 31 * result + rating;
        return result;
    }

    @Override
    public String toString() {
        return id + "|" + name + "|" + director + "|" + year + "|" + rating;
    }
}
